package com.dlwx.firefighting.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.interfaces.OnItemClickListener;
import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
import com.github.jdsjlzx.interfaces.OnRefreshListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.github.jdsjlzx.recyclerview.ProgressStyle;
import com.dlwx.firefighting.R;
import com.dlwx.firefighting.adapter.IntegralDetailAdapter;
import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 积分明细
 */
public class IntegralDetailActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.integral_empty_view)
    AutoLinearLayout emptyView;


    private LRecyclerView recyclerView = null;
    private IntegralDetailAdapter adapter = null;
    private LRecyclerViewAdapter lRecyclerViewAdapter = null;
    private static final int TOTAL_COUNTER = 13;
    private static final int REQUEST_COUNT = 10;
    private static int mCurrentCounter = 0;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_integral_detail);
        ButterKnife.bind(this);
        titleLeftOneBtn.setVisibility(View.VISIBLE);
        tvMiddleTitle.setText("积分明细");
        recyclerView = (LRecyclerView) findViewById(R.id.integral_detail_recycler);

        initRecy();
    }

    private void initRecy() {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new IntegralDetailAdapter(this);
        lRecyclerViewAdapter = new LRecyclerViewAdapter(adapter);
        recyclerView.setAdapter(lRecyclerViewAdapter);

        DividerDecoration divider = new DividerDecoration.Builder(this)
                .setHeight(R.dimen.line_height)
                .setPadding(R.dimen.size_10dp)
                .setColorResource(R.color.line_gray)
                .build();

        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(divider);

        recyclerView.setRefreshProgressStyle(ProgressStyle.LineSpinFadeLoader);
        recyclerView.setArrowImageView(R.drawable.ic_pulltorefresh_arrow);
        recyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallSpinFadeLoader);

        //设置下拉刷新
        recyclerView.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh() {
                adapter.clear();
                lRecyclerViewAdapter.notifyDataSetChanged();
                mCurrentCounter = 0;

            }
        });
        //设置上拉加载更多
        recyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore() {

            }
        });
        //设置头部加载颜色
        recyclerView.setHeaderViewColor(R.color.colorAccent, R.color.fuzhu_black, R.color.white);
        //设置底部加载颜色
        recyclerView.setFooterViewColor(R.color.colorAccent, R.color.fuzhu_black, R.color.white);
        //设置底部加载文字提示
        recyclerView.setFooterViewHint("加载中", "就这么多了", "网络不给力啊，点击再试一次吧");
        // lRecyclerViewAdapter.removeFooterView();
        //初始化数据

        lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

            }
        });
    }


    @OnClick(R.id.title_left_one_btn)
    public void onViewClicked() {
        finish();
    }
}
